//
//  UIView+Extensions.swift
//  EasePods
//
//  Created by 李然 on 2024/4/29.
//

import UIKit
import SwiftEntryKit

extension UIView {
    
    static func dismissSheet() {
        SwiftEntryKit.dismiss()
    }
    
    static func showSheet(with view: UIView) {
        var attributes = EKAttributes.bottomFloat
        attributes.entryBackground = .color(color: .white)
        attributes.screenBackground = .color(color: EKColor(R.color.common_15_mask() ?? .clear))
        //遮罩层触摸是忽略、转发到窗口还是退出
        attributes.scroll = .disabled
        attributes.screenInteraction = .dismiss
        attributes.entryInteraction = .absorbTouches
        attributes.entranceAnimation = .translation
        attributes.exitAnimation = .translation
        attributes.displayDuration = .infinity
        attributes.statusBar = .dark
        attributes.positionConstraints.verticalOffset = 0
        attributes.positionConstraints.safeArea = .overridden
        SwiftEntryKit.display(entry:view, using: attributes)
    }
    
    static func showFullScreen(with view: UIView) {
        var attributes = EKAttributes.centerFloat
        //遮罩层触摸是忽略、转发到窗口还是退出
        attributes.scroll = .disabled
        attributes.entranceAnimation = .none
        attributes.exitAnimation = .none
        attributes.displayDuration = .infinity
        attributes.statusBar = .light
        attributes.positionConstraints.verticalOffset = 0
        attributes.positionConstraints.safeArea = .overridden
        SwiftEntryKit.display(entry:view, using: attributes)
    }
}
